from pom.base_page import BasePage
from pom.login_page import LoginPage
from pom.sys_manage_page import SysManagePage
from pom.market_manage_page import MarketManagePage
from pom.sys_monitor_page import SysMonitorPage
from pom.sys_tool_page import SysToolPage
from pom.audit_manage_page import AuditManagePage
from pom.sys_setting_page import SysSettingPage
from pom.info_manage_page import InfoManagePage
from pom.log_manage_page import LogManagePage
from pom.order_manage_page import OrderManagePage
from pom.data_source_manage_page import DataSourceManagePage
from pom.engine_manage_page import EngineManagePage


from selenium.webdriver.common.by import By
from env.config import conf


class MainPage(BasePage):
    def go_to_main_page(self):
        self.driver.get(conf['env']['test']['webpage'])
        return self

    def go_to_login_page(self):
        return LoginPage(self.driver)

    def go_to_sys_manage_page(self):
        """
        进入系统管理页
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[2]/li').click()
        return SysManagePage(self.driver)

    def go_to_sys_monitor_page(self):
        """
        进入系统监控页面
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[3]/li').click()
        return SysMonitorPage(self.driver)

    def go_to_sys_tool_page(self):
        """
        进入系统工具页面
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[4]/li').click()
        return SysToolPage(self.driver)

    def go_to_market_manage_page(self):
        """
        进入市场管理页
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[6]/li/div').click()

        return MarketManagePage(self.driver)

    def go_to_audit_manage_page(self):
        """
        进入审核管理页
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[7]/li/div').click()

        return AuditManagePage(self.driver)

    def go_to_sys_setting_page(self):
        """
        进入系统设置页
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[8]/li/div').click()

        return SysSettingPage(self.driver)

    def go_to_info_manage_page(self):
        """
        进入信息管理页
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[9]/li/div').click()

        return InfoManagePage(self.driver)

    def go_to_log_manage_page(self):
        """
        进入日志管理页
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[10]/li/div').click()

        return LogManagePage(self.driver)

    def go_to_order_manage_page(self):
        """
        进入订单管理页
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[11]/li/div').click()

        return OrderManagePage(self.driver)

    def go_to_data_source_manage_page(self):
        """
        进入数据源管理页
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[12]/li/div').click()

        return DataSourceManagePage(self.driver)

    def go_to_engine_manage_page(self):
        """
        进入数据源管理页
        :return:
        """
        self.driver.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div/ul/div[13]/li/div').click()

        return EngineManagePage(self.driver)
